<script setup lang="ts">
import { useSysStore } from "@/pinna/sys";
import { useUserStore } from "@/pinna/userinfo";
import { computed, reactive } from "vue";

const title = computed(() => useSysStore().getTitle);
const userinfo: any = computed(() => useUserStore().getUser);
const breadCrumb: any = computed(() => useSysStore().getBreadCrumb);
</script>

<template>
  <el-row id="head-container">
    <el-col id="head-container-left" :span="4">{{ title }}</el-col>
    <el-col id="head-container-right" :span="20">
      <el-avatar shape="circle" fit="fill" :src="userinfo?.headImgUrl" />
      &nbsp;
      <el-dropdown>
        <el-button type="primary">
          {{ userinfo?.username
          }}<el-icon class="el-icon--right"><arrow-down /></el-icon>
        </el-button>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>修改密码</el-dropdown-item>
            <el-dropdown-item>退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </el-col>
  </el-row>
  <div id="content-container">
    <el-row>
      <el-col :span="3">
        <menu-parent></menu-parent>
      </el-col>
      <el-col :span="21">
        <div>
          <el-breadcrumb separator="/">
            <template v-for="useMenu in breadCrumb">
              <el-breadcrumb-item v-if="useMenu.resourceType == 'M'" :to="{name:useMenu.extInfo.name}">
                {{ useMenu.resourceName }}
              </el-breadcrumb-item>
              <el-breadcrumb-item v-else>
                {{ useMenu.resourceName }}
              </el-breadcrumb-item>
            </template>
          </el-breadcrumb>
        </div>
        <router-view></router-view>
      </el-col>
    </el-row>
  </div>
</template>

<style scoped>
#head-container {
  display: flex;
  justify-content: space-between;
  height: 4.5rem;
}

#head-container-left {
  padding: 1rem;
  font-size: 1.5rem;
}

#head-container-right {
  padding: 1rem;
  line-height: 2.5rem;
  min-width: 50rem;
  text-align: right;
}

#head-container-right > * {
  vertical-align: middle;
}
</style>
